1. Field of the Invention
The present invention concerns a method for reducing bus contention between two processors that communicate via a shared memory. More particularly, the present invention relates to a method in which the contention between a sending processor which writes data into a shared memory and a receiving processor which reads data out of a shared memory is reduced by causing the sending processor to cease its writing at predetermined points in the memory and wait until the receiving processor has read out the data that the sending processor has written.
2. Incorporation by Reference
U.S. patent application Ser. No. 07/978,369pending, entitled "Method And Apparatus For Interfacing A Peripheral To A Local Area Network", is hereby incorporated by reference.
3. Description of the Related Art
In a multi-processor system, it has become common in recent years for each of the processors to communicate with the other processors through a shared RAM. For example, to carry out communications in a two-processor system, a first processor would write information into shared RAM, and notify a second processor that information is available for it in the shared RAM. The second processor would then read the information from the shared RAM, write a response back into the shared RAM, and notify the first processor of the existence of the response. Access by one processor is held off until access by the other is complete. By repeating this back-and-forth reading and writing cycle, communication between the two processors can be carried out.
It is common to configure the memory of a shared RAM as a ring buffer, in which a linear memory array is addressed circularly so that addressing automatically restarts at the beginning of the buffer when the end is reached. Such a structure requires two pointers: a "put" pointer which marks the next address in which data are to be written, and a "get" pointer which marks the next address from which data are to be read. The values of these pointers are stored in the shared RAM itself. The sending processor controls the value of the put pointer, advancing it as it writes new data into the ring buffer, while the receiving processor controls the value of the get pointer, advancing it as it copies data out.
In conventional shared memory systems, before writing a block of data into shared RAM, the sending processor reads the values of the put and get pointers and compares them to determine whether there is available room in the ring buffer. Similarly, the receiving processor reads the values of the put and get pointers and compares them to determine whether there is data to be read. Thus, in transferring data from one processor to another using a ring buffer, the receiving processor follows the sending processor "around the ring", reading out the data that has been written.
If the sending processor writes data in faster than the receiving processor can read it out, it is likely that, in a conventional system, the put pointer will loop around the ring and "catch up" with the get pointer that is behind it. In such a case, the sending processor waits until memory space becomes available in the ring buffer. During that waiting time, the sending processor reads and compares the put and get pointers periodically to determine if space has become available. Such polling by the sending processor slows down the receiving processor, however, since the sending processor must access the shared RAM to read the values of the pointers, which prevents access by the receiving processor during polls of the put and get pointers and degrades performance of the entire system.